import { _decorator, Component, Node, tween, Vec3, Animation} from 'cc';
const { ccclass, property } = _decorator;

@ccclass('JumpEffect')
export class JumpEffect extends Component {
    @property(Node)
    targetNode: Node = null!;  // 目标节点

    @property(Node)
    fissureNode: Node = null!;  // 裂缝节点

    @property
    duration: number = 1;  // 动画的持续时间

    @property
    height: number = 500;  // 跳跃的初始高度

    start() {
        this.jump();
    }

    jump() {

        this.scheduleOnce(()=>{
            this.fissureNode.getComponent(Animation).play();

        },1)
        // 使用 tween 动画系统来模拟弹跳效果
        tween(this.targetNode).
        // set({angle: 90,position: new Vec3(-447, 400, 0)}).
        // to(2, { angle: 0, position: new Vec3(-447, -136, 90) ,}, {
        //     easing: 'quintInOut',
        // }).start();   
    
        set({angle: -90,position: new Vec3(-324, 620, 0)}).
        to(2, { angle: -30, position: new Vec3(-324, 0, 0) ,}, {
            easing: 'bounceOut',
        }).start();
        // to(1, { scale:new Vec3(1.5, 0.5, 0)}, {
        //     easing: 'quintInOut',
        // }).
        // to(1, { scale:new Vec3(1, 1, 0)}, {
        //     easing: 'quintInOut',
        // })
        // .start();

    }

}
